package vn.com.bookstore.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import vn.com.bookstore.domain.model.Banner;
import vn.com.bookstore.domain.model.SearchResult;
import vn.com.bookstore.service.BannerService;

@Controller
public class ManageBannersController {

	@Autowired
	private BannerService bannerService;
	
	@RequestMapping(value="/online/ajax/getBannerTop", method=RequestMethod.GET)
	public @ResponseBody ModelAndView getBannerTop(){
		ModelAndView model = new ModelAndView("website/banners/banner-top");
		SearchResult<Banner> result = bannerService.getBannerTop();
		model.addObject("bannerList", result.getSearchResult());		
		return model;
	}
	
	@RequestMapping(value="/online/ajax/getAdvertising", method=RequestMethod.GET)
	public @ResponseBody ModelAndView getAdvertising(){
		ModelAndView model = new ModelAndView("website/banners/advertising");
		SearchResult<Banner> result = bannerService.getAdvertising();
		model.addObject("bannerList", result.getSearchResult());		
		return model;
	}
}
